import javax.xml.*;

public class Main {
	Point p1 = new Point(5,40)
		, p2 = new Point(95,50)
		, p3 = new Point(5,60)
		, p4 = new Point(70,40);
	Line line1 = new Line(p1,p2);
	Line line2 = new Line(p3,p4);
	
	public Main() {
		/*
		System.out.println("Equation of line1: " + line1);
		System.out.println("Equation of line1: " + line2);
		
		System.out.println("\nPoint of intersection: " + line1.intersections(line2).get(0) + "\n");
		
		System.out.println("Integral over entire line1: " + line1.integral(p1, p2));
		System.out.println("Integral over entire line2: " + line2.integral(p3, p4));
		*/
		/* * * Calculate our messure of differnece betwen the two lines * * */

		// Right-most of the two left-most endpoints
		Point e1 = line1.getEnd1().getX() > line2.getEnd1().getX() ? line1.getEnd1() : line2.getEnd1();
		// Left-most of the two right-most endpoints
		Point e2 = line1.getEnd2().getX() < line2.getEnd2().getX() ? line1.getEnd2() : line2.getEnd2();
		// Intersection
		Point p = line1.intersections(line2).get(0);

		// Get differences
		double d1 = line1.integral(e1, p) - line2.integral(e1, p);
		double d2 = line1.integral(p, e2) - line2.integral(p, e2);
		
		String svg = 
"<?xml version=\"1.0\" standalone=\"no\"?>\n" + 
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n\n" +

"<svg width=\"16cm\" height=\"16cm\" viewBox=\"0 0 100 100\"\n"+
"	xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n"+
"	<title>Example triangle01- simple example of a 'path'</title>\n"+

"	<rect x=\"1\" y=\"1\" width=\"98\" height=\"98\"\n"+
"		fill=\"none\" stroke=\"blue\" />\n"+

"	<path d=\""+
			"M " + p1.getX() + " " + p1.getY() + 
			" L " + p3.getX() + " " + p3.getY() +
			" L " + p.getX() + " " + p.getY() + 
			" z " +
			"\"\n" +
"		fill=\"red\" stroke=\"none\" />\n"+

"	<path d=\""+
			"M " + p.getX() + " " + p.getY() + 
			" L " + p4.getX() + " " + p4.getY() +
			" L " + p4.getX() + " " + line1.getY(p4.getX()) + 
			" z " +
			"\"\n" +
"		fill=\"green\" stroke=\"none\" />\n"+

"	<path d=\""+
			"M " + p1.getX() + " " + p1.getY() + 
			" L " + p2.getX() + " " + p2.getY() +
			"\"\n" +
"		fill=\"none\" stroke=\"#993\" /> \n"+
"	<path d=\""+
			"M " + p3.getX() + " " + p3.getY() +
			" L " + p4.getX() + " " + p4.getY() +
			"\"\n" +
"		fill=\"none\" stroke=\"#339\" /> \n"+

"	<rect x=\""+ (p.getX()-1) +"\" y=\""+ (p.getY()-1) +"\" width=\"2\" height=\"2\"\n"+
"		fill=\"none\" stroke=\"yellow\" />\n"+
"</svg>\n";
		System.out.println(svg);
	}

	public static void main(String[] argv) { new Main(); }
}
